package com.briup.mt.web.controller;

import com.briup.mt.bean.Counsel;
import com.briup.mt.service.ICounselService;
import com.briup.mt.service.impl.CounselServiceImpl;
import com.briup.mt.utils.Message;
import com.briup.mt.utils.MessageUtil;
import io.swagger.annotations.ApiImplicitParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @program: app03
 * @description: 账户的控制器类
 * @author: charles
 * @create: 2020-12-14 16:20
 **/
@RestController
@RequestMapping("/counsel")


public class CounselController {
    @Autowired
    private CounselServiceImpl counselService;

    @GetMapping("query")
    public Message query(String question,String status){
        List<Counsel> list =  counselService.query(question,status);
        return MessageUtil.success(list);
    }

    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(Counsel info){
        counselService.saveOrUpdate(info);
        return MessageUtil.success("操作成功");
    }

    @DeleteMapping("deleteById")
    public Message deleteById(Long id){
        counselService.deleteById(id);
        return MessageUtil.success("删除成功");
    }

}
